angular.module('swipe-list', [])

.directive 'swipeList', ->
    restrict    : 'E'
    templateUrl : 'templates/swipe-list/swipe-list.html'
    scope:
        'items' : '=items'
        'itemsUserTypeList':'=itemsUserTypeList'
        'itemClick':'=itemClick'
        'itemRemove':'=itemRemove'
        'needOnLine':'=needOnLine'
        'itemOnHold':'=itemOnHold'
        'needSendAll':'=needSendAll'
        'needDownLine':'=needDownLine'
        'currentItem':'=currentItem'
        'isVip':'=isVip'
        'itemRevise':'=itemRevise'
        'itemShare':'=itemShare'
        'itemIncrease':'=itemIncrease'
        'itemReset':'=itemReset'
        'itemTypeChange':'=itemTypeChange'
    link: ($scope, $element, $attrs) ->
.controller 'swipeListCtrl', ($scope,$cordovaSms,$state) ->
    $scope.list = []
    _.defer ->
        _.each $scope.items,(item)->
            item.isCheckIn = false

    _.extend $scope,
        sendMessage: (item,e)->
            console.log 'item.txt1',item.username
            $scope.itemOnHold(item)
            e.stopPropagation()
        pick: (i,e,currentItem)->
            e.stopPropagation()
            if $scope.needOnLine or $scope.needDownLine
                $scope.items[i].isCheckIn = !$scope.items[i].isCheckIn
                return
            $scope.itemClick(i,currentItem)
        remove: (i,e)->
            e.stopPropagation()
            $scope.itemRemove(i)
        share: (i,e)->
            e.stopPropagation()
            $scope.itemShare(i)
        revise: (i,e) ->
            e.stopPropagation()
            $scope.itemRevise(i)
        onLine: (i,e)->
            console.log '上架'
            e.stopPropagation()
        checkIn: (i,e)->
            console.log '选中'
            e.stopPropagation()
            $scope.items[i].isCheckIn = !$scope.items[i].isCheckIn
        goAccount:(item,e) ->
            console.log 'item',item
            $scope.itemIncrease(item)
            e.stopPropagation()
        goReset:(item,e) ->
            console.log 'item',item
            $scope.itemReset(item)
            e.stopPropagation()
        changeType:(item) ->
            console.log 'item',item
            $scope.itemTypeChange(item)





